package com.tengju.bff.infrastructure.persistence.redis;

import com.tengju.bff.domain.service.WxLockService;
import com.tengju.bff.infrastructure.persistence.redis.dataobject.RedisKeyObject;
import com.tengju.bff.infrastructure.persistence.redis.dataobject.RedisKeyPrefix;
import lombok.RequiredArgsConstructor;
import org.redisson.api.RLock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author: 李大仙
 * @date: 2021/11/17 4:37 下午
 */
@Service
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class WxLockServiceImpl implements WxLockService {

    private final RedisService redisService;

    @Override
    public RLock getLock(String key) {
        RedisKeyObject redisKeyObject = new RedisKeyObject(RedisKeyPrefix.WX_USER_DEPARTMENT_MANAGE_JOB, key);
        return redisService.getLock(redisKeyObject);
    }
}
